package com.futures.investm.fragment;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.futures.investm.R;
import com.futures.investm.adapter.MarketForeignAdapter;
import com.futures.investm.constant.Api;
import com.futures.investm.entity.MarketInfo;
import com.vise.xsnow.http.ViseHttp;
import com.vise.xsnow.http.callback.ACallback;
import com.vise.xsnow.http.request.GetRequest;

import java.util.ArrayList;

import butterknife.BindView;
import tech.com.commoncore.base.BaseFragment;
import tech.com.commoncore.entity.BaseTResp;

/**
 * 行情--》行情
 */
public class MarketToMarketFragment extends BaseFragment {
    @BindView(R.id.rv)
    RecyclerView rv;


    //外汇
    MarketForeignAdapter mMarketForeignAdapter;


    public static MarketToMarketFragment newInstance() {
        Bundle args = new Bundle();
        MarketToMarketFragment fragment = new MarketToMarketFragment();
        fragment.setArguments(args);
        return fragment;
    }


    @Override
    public int getContentLayout() {
        return R.layout.fragment_market_to_market;
    }

    @Override
    public void initView(Bundle savedInstanceState) {
        //外汇
        rv.setLayoutManager(new LinearLayoutManager(mContext));
        mMarketForeignAdapter = new MarketForeignAdapter();
        getForeign();
        rv.setAdapter(mMarketForeignAdapter);

    }

    /**
     * 外汇
     */
    private void getForeign() {
        GetRequest request = ViseHttp.GET(Api.MARKET_URL);
        request.request(new ACallback<BaseTResp<ArrayList<MarketInfo>>>() {
            @Override
            public void onSuccess(BaseTResp<ArrayList<MarketInfo>> data) {

                mMarketForeignAdapter.setNewData(data.data);

            }

            @Override
            public void onFail(int errCode, String errMsg) {
            }
        });
    }


}
